package TextEditor.facade;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;

import javax.swing.JTextArea;

/**
 * Implementation of FileInterface to copy selected text
 * @author Yij_Zhan *
 */
public class CopyOperation implements FileInterface {
	
	Toolkit toolkit = Toolkit.getDefaultToolkit();
	Clipboard clipBoard = toolkit.getSystemClipboard();
	
	
	@Override
	public void fileOperation(JTextArea textArea) {
		//@ZHYJ:
		textArea.requestFocusInWindow();
		String copyString = textArea.getSelectedText();
		StringSelection selection = new StringSelection(copyString);
		clipBoard.setContents(selection,null);
	}

}
